home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12517 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.4 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Borland C's tmpnam()
  5. Date: Mon, 01 Apr 96 12:41:02 GMT
  6. Organization: none
  7. Message-ID: <828362462snz@genesis.demon.co.uk>
  8. References: <AD84A73496681719A2@mcdiala03.it.luc.edu>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <AD84A73496681719A2@mcdiala03.it.luc.edu>
  15.            VArase@varase.it.luc.edu "Verne Arase" writes:
  16.  
  17. >In article <828276946snz@genesis.demon.co.uk>,
  18. >Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
  19. >
  20. > >>I thought that only DOS/Intel offspring platforms were supported; that's
  21. > >>why I limited my query to that specific compiler; else I would've
  22. >included
  23. > >>the target environment.
  24. > >
  25. > >Don't forget that you are posting to comp.lang.c where the bias is for
  26. > >discussing the standard, platform-independent, C language. The place to
  27. > >discuss the specific traits and extensions of Borland C is somewhere
  28. > >like comp.os.msdos.programmer.
  29. >
  30. >Don't forget the subject line. I didn't ask a general question re:
  31. >tmpnam(); I put it in the context of Borland C. If I'd asked the question
  32. >in the context of CodeWarrior, I'd have expected someone with some
  33. >Macintosh experience to respond.
  34. >
  35. >The newsgroup is called comp.lang.c, not comp.lang.x-platform.c.
  36.  
  37. Exactly - comp.lang.c is a platform-independent newsgroup. When you start
  38. asking platform-specific questions you are posting to the wrong newsgroup.
  39. However discussing what the standard requires is relevant to any compiler
  40. that claims to be conforming.
  41.  
  42. > >>If you're stating that tmpnam() under Borland C does indeed check to see
  43. > >>that the file name is unique, I'll quash that reluctance and change the
  44. > >>default directory.
  45. > >
  46. > >I don't know what Borland C actually does. It it is a conforming
  47. > >implementation it must ensure that the name it generates is valid and
  48. > >doesn't already exist in the filesystem.
  49. >
  50. >Actually, it doesn't.
  51. >
  52. >All it does it insure that the file name doesn't exist in the current
  53. >location in the file system. Which, I'd imagine, is what just about every
  54. >implementation does.
  55.  
  56. In a hierarchical filesystem a file is uniquely identified by its full
  57. path name. So to ensure "filename" doesn't already exist in the filesystem
  58. it just nees to ensure that, for example,
  59.  
  60.     fopen("filename", mode)
  61.  
  62. is valid and doesn't refer to an existing file.
  63.  
  64. >It's be a lot more useful if you could specify a target directory, though
  65. >the string that makes up that specification would be target environment
  66. >dependant.
  67.  
  68. Unfortuately standard C has no concept of directories so this would make
  69. no sense as a standard C feature. If I care about what directory it goes
  70. in I usually care about what filename is generated and I'd generate my own.
  71. A bigger problem is that filename generation and (possible) creation of
  72. the file are distinct operations which could cause problems on a
  73. multitasking system. What you really need is a function that will open/create
  74. a new file, a bit like tmpfile() except that it also returns a file name.
  75. You can't write this in standard C but on systems that support a POSIX-like
  76. open() you can use that to build such a function.
  77.  
  78. -- 
  79. -----------------------------------------
  80. Lawrence Kirby | fred@genesis.demon.co.uk
  81. Wilts, England | 70734.126@compuserve.com
  82. -----------------------------------------
  83.